import java.util.Arrays;
class Student{
    public String name;
    public int age;

    Student(String name,int age){
        this.name = name;
        this.age = age;
    }
}
public class test {
    public static void main(String[] args) {
        String s = "hello world k";
        String[] array = s.split(" ");
        System.out.println(Arrays.toString(array));

        String s1 = "hello world k";
        String[] array1 = s.split(" ",2);
        // 以空格分割最多分成两组
        System.out.println(Arrays.toString(array1));
    }
    public static void main4(String[] args) {
        String s = "hello";
        // int a = Integer.parseInt("190");
        // System.out.println(a);

       //  String ret = s.toUpperCase();
       // System.out.println(ret);

        char[] ret1 = s.toCharArray();
        System.out.println(Arrays.toString(ret1));
    }
    public static void main3(String[] args) {
        String s1 = new String("hello");
        char ch = s1.charAt(1);
        System.out.println(ch);

        // String s2 = new String("hello");
        // int index = s1.indexOf('l',3);
        // System.out.println(index);// 3

        /*String s3 = "ababcabcd";
        int index = s3.lastIndexOf("abc",4);
        System.out.println(index);// 2 */

        String s2 = String.valueOf(new Student("zhangsan",20));
        System.out.println(s2);

        String s3 = String.valueOf(123);
        System.out.println(s3);

        String s4 = String.valueOf(123.34);
        System.out.println(s4);

        String s5 = String.valueOf(true);
        System.out.println(s5);// true
    }
    public static void main2(String[] args) {
        String s1 = new String("hello");
        String s2 = new String("Hello");
        System.out.println(s1 == s2);
        // 不等于,s1和s2表示对象的引用都存的是地址

        System.out.println(s1.equals(s2));
        System.out.println(s1.compareTo(s2));
        // s1 大于 s2 返回正数
        // s1 小于 s2 返回负数
        // s1 等于 s2 返回0
        System.out.println(s1.compareToIgnoreCase(s2));
        // 忽略大小写比较
    }
    public static void main1(String[] args) {
        // 用常量字符串构造
        String s1 = "hello";
        System.out.println(s1);

        // 用字符数组构造
        char[] array = new char[]{'a','b','c'};
        String s2 = new String(array);
        System.out.println(s2);

        char[] array1 = new char[]{'a','b','c'};
        String s4 = new String(array,0,2);
        // 从0位置后拿2个字符
        System.out.println(s4);

        // 直接newSting对象构造
        String s3 = new String("hello");
        System.out.println(s3);
    }
}
